Example usage for com.google.gwt.gdata.client.gbase ItemsEntryCallback ItemsEntryCallback

List of usage examples for com.google.gwt.gdata.client.gbase ItemsEntryCallback ItemsEntryCallback

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.gbase ItemsEntryCallback ItemsEntryCallback.

Prototype

ItemsEntryCallback

Source Link

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseCreateItemDemo.java

License:Apache License

/**
 * Create an item by inserting an item entry into
 * an items feed.//from www  . j a va2  s  .c o m
 * Set the item's title to an arbitrary string. Here
 * we prefix the title with 'GWT-GoogleBase-Client' so that
 * we can identify which items were created by this demo.
 * The new item is created as a product review with values
 * for the default product review attributes.
 * On success and failure, display a status message.
 * 
 * @param itemsFeedUri The uri of the items feed into which
 * to insert the new item entry
 */
private void createItem(String itemsFeedUri) {
    showStatus("Creating item...", false);
    ItemsEntry entry = ItemsEntry.newInstance();
    entry.setTitle(Text.newInstance());
    entry.getTitle().setText("GWT-GoogleBase-Client - inserted item");
    entry.setContent(Text.newInstance());
    entry.getContent().setText("GData is great data!! :)");

    Attribute targetCountry = Attribute.newInstance();
    targetCountry.setValue("US");
    Attribute reviewType = Attribute.newInstance();
    reviewType.setValue("Product Review");
    Attribute nameOfItem = Attribute.newInstance();
    nameOfItem.setValue("gwt-gdata");
    Attribute expirationDate = Attribute.newInstance();
    expirationDate.setValue("2038-01-19T03:14:07Z");
    Attribute rating = Attribute.newInstance();
    rating.setValue("5-Excellent");
    Attribute customerId = Attribute.newInstance();
    customerId.setValue("5752122");
    Attribute itemType = Attribute.newInstance();
    itemType.setValue("Reviews");
    Attribute itemLanguage = Attribute.newInstance();
    itemLanguage.setValue("en");

    entry.setAttribute("target_country", targetCountry);
    entry.setAttribute("review_type", reviewType);
    entry.setAttribute("name_of_item_reviewed", nameOfItem);
    entry.setAttribute("expiration_date", expirationDate);
    entry.setAttribute("rating", rating);
    entry.setAttribute("customer_id", customerId);
    entry.setAttribute("item_type", itemType);
    entry.setAttribute("item_language", itemLanguage);

    service.insertEntry(itemsFeedUri, entry, new ItemsEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while creating an item: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsEntry result) {
            showStatus("Created an item.", false);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseDeleteItemDemo.java

License:Apache License

/**
 * Delete an item entry using the Finance service and
 * the item entry uri./*from   www . j  a  v a 2 s  . c o m*/
 * On success and failure, display a status message.
 * 
 * @param itemsEntryUri The uri of the item entry to delete
 */
private void deleteItem(String itemsEntryUri) {
    showStatus("Deleting item...", false);
    service.deleteEntry(itemsEntryUri, new ItemsEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while deleting an item: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsEntry result) {
            showStatus("Deleted an item.", false);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseUpdateItemDemo.java

License:Apache License

/**
 * Update an item by making use of the updateEntry
 * method of the Entry class.//from   w  ww . j  ava2 s. c om
 * Set the item's title to an arbitrary string. Here
 * we prefix the title with 'GWT-GoogleBase-Client' so that
 * we can identify which items were updated by this demo.
 * We also update the target_country property for this item.
 * On success and failure, display a status message.
 * 
 * @param itemsEntry The item entry which to update
 */
private void updateItem(ItemsEntry itemsEntry) {
    showStatus("Updating item...", false);
    itemsEntry.setTitle(Text.newInstance());
    itemsEntry.getTitle().setText("GWT-GoogleBase-Client - updated item");
    MapAttribute attributes = itemsEntry.getAttributes();
    if (attributes.contains("target_country")) {
        attributes.get("target_country")[0].setValue("UK");
    }
    itemsEntry.updateEntry(new ItemsEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while updating an item: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsEntry result) {
            showStatus("Updated an item.", false);
        }
    });
}