Example usage for com.google.gwt.gdata.client.gbase ItemsEntry newInstance

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

Introduction

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

Prototype

public static native ItemsEntry newInstance() ;

Source Link

Document

Constructs a Google Base item entry.

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./* w  w  w . jav a2  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);
        }
    });
}