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
action.next_page= >>
action.prev_page= <<
label.next_page_tooltop=Next Page
-label.prev_page_tooltop=Previous Page
\ No newline at end of file
+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.
/**
* 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
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;
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 = "";
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;
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 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;
-
public GFTSPanel()
{
try
}
txt_search.setToolTipText(JvSwingUtils.wrapTooltip(true,
tooltipText));
- searchAction();
+ searchAction(true);
}
});
{
if (!getTypedText().equalsIgnoreCase(lastSearchTerm))
{
- searchAction();
+ searchAction(true);
lastSearchTerm = getTypedText();
}
}
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]);
{
btn_back.setEnabled(true);
btn_cancel.setEnabled(true);
+ refreshPaginatorState();
+ txt_search.setEnabled(true);
+ cmb_searchTarget.setEnabled(true);
if (wantedFieldsUpdated())
{
- searchAction();
+ searchAction(true);
}
else
{
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 >= pageLimit)
+ {
+ setNextPageButtonEnabled(true);
+ }
+ if (offSet >= pageLimit)
+ {
+ setPrevPageButtonEnabled(true);
+ }
+ }
public void referesh()
{
mainFrame.setTitle(getFTSFrameTitle());
public PDBFTSPanel(SequenceFetcher seqFetcher)
{
+ pageLimit = PDBFTSRestClient.getInstance().getDefaultResponsePageSize();
this.seqFetcher = seqFetcher;
this.progressIdicator = (seqFetcher == null) ? null : seqFetcher
.getProgressIndicator();
@Override
- public void searchAction()
+ public void searchAction(boolean isFreshSearch)
{
+ if (isFreshSearch)
+ {
+ offSet = 0;
+ }
new Thread()
{
@Override
request.setResponseSize(100);
request.setFieldToSearchBy("(" + searchTarget + ":");
request.setSearchTerm(searchTerm + ")");
+ request.setOffSet(offSet);
request.setWantedFields(wantedFields);
FTSRestClientI pdbRestCleint = PDBFTSRestClient.getInstance();
FTSRestResponse resultList;
}
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();
false);
} catch (Exception e)
{
- // TODO Auto-generated catch block
e.printStackTrace();
}
int[] selectedRows = getResultTable().getSelectedRows();
return pdbIdWithChainCode;
}
-
-
@Override
public FTSRestClientI getFTSRestClient()
{
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;
}
}
.getWantedFields());
int responseSize = (pdbRestRequest.getResponseSize() == 0) ? getDefaultResponsePageSize()
: pdbRestRequest.getResponseSize();
+ int offSet = pdbRestRequest.getOffSet();
String sortParam = null;
if (pdbRestRequest.getFieldToSortBy() == null
|| pdbRestRequest.getFieldToSortBy().trim().isEmpty())
.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);
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);
}
else
{
errorMessage = getMessageByHTTPStatusCode(clientResponse
- .getStatus());
+.getStatus(), "PDB");
throw new Exception(errorMessage);
}
}
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
{
}
}
- 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.
{
return Objects.hash(primaryKey1, this.toString());
}
+
+ @Override
+ public boolean equals(Object that)
+ {
+ return this.toString().equals(that.toString());
+ }
};
}
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;
@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();
+ 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);
- // 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
- 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)
}
return result;
}
+
public static FTSData getFTSData(String tabDelimittedDataStr,
FTSRestRequest request)
{
{
return Objects.hash(primaryKey1, this.toString());
}
+
+ @Override
+ public boolean equals(Object that)
+ {
+ return this.toString().equals(that.toString());
+ }
};
}
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
wantedFields = UniProtFTSRestClient.getInstance()
.getAllDefaulDisplayedDataColumns();
- String searchTerm = txt_search.getText();
+ String searchTerm = decodeSearchTerm(txt_search.getText(),
+ searchTarget);
FTSRestRequest request = new FTSRestRequest();
request.setFieldToSearchBy(searchTarget);
}
-
-
- 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()