List of usage examples for com.google.gwt.gdata.client.finance PortfolioFeedCallback PortfolioFeedCallback
PortfolioFeedCallback
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceCreateTransactionDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining success * and failure handlers.//from www. j a v a 2s . co m * Here, the failure handler displays an error message while the * success handler obtains the first Portfolio entry with a title * starting with "GWT-Finance-Client" and calls createTransaction * to insert a transaction. * If no portfolio is found a message is displayed. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { String portfolioEditUri = targetPortfolio.getEditLink().getHref(); createTransaction(portfolioEditUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceDeletePortfolioDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining success * and failure handlers.//www . j ava2 s .co m * Here, the failure handler displays an error message while the * success handler obtains the first Portfolio entry with a title * starting with "GWT-Finance-Client" and calls deletePortfolio * to delete the portfolio. Alternatively we could also have used * targetPortfolio.deleteEntry but the effect is the same. * If no portfolio is found a message is displayed. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios " + "feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { String portfolioEntryUri = targetPortfolio.getSelfLink().getHref(); deletePortfolio(portfolioEntryUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceDeleteTransactionDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining success * and failure handlers./* w w w .j a v a2 s .co m*/ * Here, the failure handler displays an error message while the * success handler obtains the first Portfolio entry with a title * starting with "GWT-Finance-Client" and retrieves the first * transaction in the portfolio with the symbol "NASDAQ:GOOG", * this is the transaction that will be deleted. * If no transaction exists with this symbol, the request will fail. * If no portfolio is found, a message is displayed. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { final String ticker = "NASDAQ:GOOG"; int transactionId = 1; String transactionEntryUri = targetPortfolio.getEditLink().getHref() + "/positions/" + ticker + "/transactions/" + transactionId; getTransaction(transactionEntryUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceRetrievePortfolioDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining success * and failure handlers.// w w w .ja v a 2 s. c o m * Here, the failure handler displays an error message while the * success handler obtains the first Portfolio entry and * calls getPortfolio. The getPortfolio call will retrieve * the same portfolio that we already have, the goal * is to exemplify how to retrieve a portfolio directly. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios " + "feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); if (entries.length == 0) { showStatus("You have no portfolios.", false); } else { PortfolioEntry targetPortfolio = entries[0]; String portfolioEntryUri = targetPortfolio.getId().getValue(); getPortfolio(portfolioEntryUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceRetrievePortfoliosDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining * success and failure handlers.//from w w w .jav a 2s. c o m * Here, the failure handler displays an error message while the * success handler calls showData to display the portfolio entries. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios " + "feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); if (entries.length == 0) { showStatus("You have no portfolios.", false); } else { showData(entries); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceRetrievePositionsDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining * success and failure handlers.//from www. java 2 s . c o m * Here, the failure handler displays an error message while the * success handler obtains the first portfolio entry and its * ID and calls getPositions to retrieve the corresponding * positions feed. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); if (entries.length == 0) { showStatus("You have no portfolios.", false); } else { PortfolioEntry targetPortfolio = entries[0]; String portfolioId = targetPortfolio.getId().getValue(); JsArrayString match = regExpMatch("\\/(\\d+)$", portfolioId); if (match.length() > 1) { portfolioId = match.get(1); } else { showStatus("Error parsing the portfolio id.", true); } getPositions(portfolioId); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceRetrieveTransactionsDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining * success and failure handlers.//from w w w.ja v a 2 s .c om * Here, the failure handler displays an error message while the * success handler obtains the first portfolio entry with a title * starting with "GWT-Finance-Client" and retrieves all transactions * with the ticker symbol "NASDAQ:GOOG". * If no transactions exist with this symbol, the request will fail. * If no portfolio is found, a message is displayed. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { String ticker = "NASDAQ:GOOG"; String transactionFeedUri = targetPortfolio.getEditLink().getHref() + "/positions/" + ticker + "/transactions"; getTransactions(transactionFeedUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceUpdatePortfolioDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining * success and failure handlers.//w ww. ja v a 2s . c om * Here, the failure handler displays an error message while the * success handler obtains the first portfolio entry with a title * starting with "GWT-Finance-Client" and calls updatePortfolio to * update the portfolio. * If no portfolio is found, a message is displayed. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { updatePortfolio(targetPortfolio); } } }); }