: uniportRestRequest.getResponseSize();
int offSet = uniportRestRequest.getOffSet();
+ String query;
+ if (isAdvancedQuery(uniportRestRequest.getSearchTerm()))
+ {
+ query = uniportRestRequest.getSearchTerm();
+ }
+ else
+ {
+ query = uniportRestRequest.getFieldToSearchBy().equalsIgnoreCase(
+ "Search All") ? uniportRestRequest.getSearchTerm()
+ + " or mnemonic:" + 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);
- // System.out.println(">>>>> Response size: " + responseSize
- // + " offset : "
- // + offSet);
WebResource webResource = null;
webResource = client.resource(UNIPROT_SEARCH_ENDPOINT)
.queryParam("format", "tab")
throw new Exception(errorMessage);
}
+ int xTotalResults = Integer.valueOf(clientResponse.getHeaders()
+ .get("X-Total-Results").get(0));
clientResponse = null;
client = null;
return parseUniprotResponse(uniProtTabDelimittedResponseString,
- uniportRestRequest);
+ uniportRestRequest, xTotalResults);
} catch (Exception e)
{
String exceptionMsg = e.getMessage();
}
}
+ public boolean isAdvancedQuery(String query)
+ {
+ if (query.contains(" AND ") || query.contains(" OR ")
+ || query.contains(" NOT ") || query.contains(" ! ")
+ || query.contains(" || ") || query.contains(" && ")
+ || query.contains(":") || query.contains("-"))
+ {
+ return true;
+ }
+ return false;
+ }
public FTSRestResponse parseUniprotResponse(
String uniProtTabDelimittedResponseString,
- FTSRestRequest uniprotRestRequest)
+ FTSRestRequest uniprotRestRequest, int xTotalResults)
{
FTSRestResponse searchResult = new FTSRestResponse();
List<FTSData> result = null;
if (foundDataRow != null && foundDataRow.length > 0)
{
result = new ArrayList<FTSData>();
- String titleRow = getDataColumnsFieldsAsTabDelimitedString(uniprotRestRequest
- .getWantedFields());
- // System.out.println(">>>>Title row : " + titleRow);
+ boolean firstRow = true;
for (String dataRow : foundDataRow)
{
- if (dataRow.equalsIgnoreCase(titleRow))
+ // The first data row is usually the header data. This should be
+ // filtered out from the rest of the data See: JAL-2485
+ if (firstRow)
{
- // System.out.println(">>>>>>>>>> matched!!!");
+ firstRow = false;
continue;
}
// System.out.println(dataRow);
result.add(getFTSData(dataRow, uniprotRestRequest));
}
- searchResult.setNumberOfItemsFound(result.size());
+ searchResult.setNumberOfItemsFound(xTotalResults);
searchResult.setSearchSummary(result);
}
return searchResult;
{
try
{
- summaryRowData[colCounter++] = (field.getDataColumnClass() == Integer.class) ? Integer
- .valueOf(fieldData)
- : (field.getDataColumnClass() == Double.class) ? Double
+ summaryRowData[colCounter++] = (field.getDataType()
+ .getDataTypeClass() == Integer.class) ? Integer
+ .valueOf(fieldData.replace(",", ""))
+ : (field.getDataType().getDataTypeClass() == Double.class) ? Double
.valueOf(fieldData) : fieldData;
} catch (Exception e)
{
e.printStackTrace();
- System.out.println("offending value:" + fieldData);
+ System.out.println("offending value:" + fieldData);
}
}
} catch (Exception e)
};
}
-
public static FTSRestClientI getInstance()
{
if (instance == null)