Example usage for com.google.gwt.gdata.client.maps FeatureEntry getSelfLink

List of usage examples for com.google.gwt.gdata.client.maps FeatureEntry getSelfLink

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.maps FeatureEntry 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.MapsDeleteMapFeatureDemo.java

License:Apache License

/**
 * Retrieve the features feed for a given map using the
 * Maps service and the features feed uri.
 * In GData all get, insert, update and delete methods always
 * receive a callback defining success and failure handlers.
 * Here, the failure handler displays an error message while the
 * success handler obtains the first feature entry with a title
 * starting with "GWT-Maps-Client" and calls deleteFeature to
 * delete the feature./* w  w  w.  j ava 2s  .co m*/
 * If no feature is found, a message is displayed.
 * 
 * @param mapEntryUri The uri of the map entry for which to
 * retrieve the features feed
 */
private void getFeatures(String mapEntryUri) {
    String featuresFeedUri = mapEntryUri.replace("/feeds/maps/", "/feeds/features/") + "/full";
    showStatus("Loading features feed...", false);
    service.getFeatureFeed(featuresFeedUri, new FeatureFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the features feed: " + caught.getMessage(), true);
        }

        public void onSuccess(FeatureFeed result) {
            FeatureEntry[] entries = result.getEntries();
            FeatureEntry targetFeature = null;
            for (FeatureEntry entry : entries) {
                if (entry.getTitle().getText().startsWith("GWT-Maps-Client")) {
                    targetFeature = entry;
                    break;
                }
            }
            if (targetFeature == null) {
                showStatus("No map feature found that contains 'GWT-Maps-Client' " + "in the title.", false);
            } else {
                String featureEntryUri = targetFeature.getSelfLink().getHref();
                deleteFeature(featureEntryUri);
            }
        }
    });
}