@Override public void showInstanceDetailsIfExists(Pathway pathway, DatabaseObject databaseObject) { view.showInstanceDetailsIfExists(pathway, databaseObject); }
@Override public void onResourceChosen(final String resource) { String url = AnalysisHelper.URL_PREFIX + "/token/" + token + "?page=1&resource=" + resource; RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url); requestBuilder.setHeader("Accept", "application/json"); try { requestBuilder.sendRequest( null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { try { AnalysisResult result = AnalysisModelFactory.getModelObject(AnalysisResult.class, response.getText()); // We have to do this here because there is no name coming from the RESTFul service result .getSummary() .setSpeciesName(speciesMap.get(result.getSummary().getSpecies())); view.clearSelection(); view.showResult(result, resource); view.selectPathway(selected); } catch (AnalysisModelException e) { MessageObject msgObj = new MessageObject( "The received object for '" + resource + "' is empty or faulty and could not be parsed.\n" + "ERROR: " + e.getMessage(), getClass(), MessageType.INTERNAL_ERROR); eventBus.fireELVEvent(ELVEventType.INTERNAL_MESSAGE, msgObj); Console.error(getClass() + " ERROR: " + e.getMessage()); view.setInitialState(); } } @Override public void onError(Request request, Throwable exception) { // TODO Check before commit - not yet tested MessageObject msgObj = new MessageObject( "The request for '" + resource + "' received an error instead of a valid response.\n" + "ERROR: " + exception.getMessage(), getClass(), MessageType.INTERNAL_ERROR); eventBus.fireELVEvent(ELVEventType.INTERNAL_MESSAGE, msgObj); Console.error(getClass() + " ERROR: " + exception.getMessage()); view.setInitialState(); } }); } catch (RequestException ex) { MessageObject msgObj = new MessageObject( "The requested detailed data for '" + resource + "'\nin the Analysis could not be received.\n" + "ERROR: " + ex.getMessage(), getClass(), MessageType.INTERNAL_ERROR); eventBus.fireELVEvent(ELVEventType.INTERNAL_MESSAGE, msgObj); Console.error(getClass() + " ERROR: " + ex.getMessage()); view.setInitialState(); } }