Example usage for com.google.gwt.gdata.client.finance PortfolioEntry getSelfLink

List of usage examples for com.google.gwt.gdata.client.finance PortfolioEntry getSelfLink

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.finance PortfolioEntry getSelfLink.

Prototype

public final native com.google.gwt.gdata.client.Link getSelfLink() ;

Source Link

Document

Returns the link that provides the URI of the feed or entry.

Usage

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./*from ww  w . java  2s  . c  o 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);
            }
        }
    });
}