Example usage for com.google.gwt.gdata.client.contacts ContactQuery SORTORDER_DESCENDING

List of usage examples for com.google.gwt.gdata.client.contacts ContactQuery SORTORDER_DESCENDING

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.contacts ContactQuery SORTORDER_DESCENDING.

Prototype

String SORTORDER_DESCENDING

To view the source code for com.google.gwt.gdata.client.contacts ContactQuery SORTORDER_DESCENDING.

Click Source Link

Document

Descending.

Usage

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

License:Apache License

/**
 * Retrieves a contacts feed using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * On success, obtain the first contact entry with a title starting
 * with "GWT-Contacts-Client", this is the contact that will be deleted.
 * If no contact is found, display a message.
 * Otherwise call deleteContact to delete the contact entry.
 * Alternatively we could also have used targetContact.deleteEntry to
 * delete the contact, but the effect is the same.
 * //from  w  w w  .j a v a2  s  . c om
 * @param contactsFeedUri The contacts feed uri.
 */
private void queryContacts(String contactsFeedUri) {
    showStatus("Querying contacts...", false);
    ContactQuery query = ContactQuery.newInstance(contactsFeedUri);
    Date today = new Date();
    DateTime updatedMin = DateTime.newInstance(today, true);
    query.setUpdatedMin(updatedMin);
    query.setSortOrder(ContactQuery.SORTORDER_DESCENDING);
    service.getContactFeed(query, new ContactFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Contacts feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactFeed result) {
            ContactEntry[] entries = result.getEntries();
            ContactEntry targetContact = null;
            for (ContactEntry contact : entries) {
                String title = contact.getTitle().getText();
                if (title.startsWith("GWT-Contacts-Client")) {
                    targetContact = contact;
                    break;
                }
            }
            if (targetContact == null) {
                showStatus("No contacts were found that were modified today and "
                        + "contained 'GWT-Contacts-Client' in the title.", false);
            } else {
                String contactEntryUri = targetContact.getEditLink().getHref();
                deleteContact(contactEntryUri, targetContact.getEtag());
            }
        }
    });
}

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

License:Apache License

/**
 * Retrieves a contacts feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * We query for contacts updated today, sorted descending.
 * Upon successfully receiving the contacts feed, the contact entries
 * are displayed to the user via the showData method.
 * The UpdatedMin and SortOrder parameters are used to limit
 * the number of contact entries retrieved and to specify how they
 * should sorted.//from w ww.j  ava2s.co  m
 * 
 * @param contactsFeedUri The contacts feed uri.
 */
private void queryContacts(String contactsFeedUri) {
    showStatus("Querying contacts...", false);
    ContactQuery query = ContactQuery.newInstance(contactsFeedUri);
    Date today = new Date();
    DateTime updatedMin = DateTime.newInstance(today, true);
    query.setUpdatedMin(updatedMin);
    query.setSortOrder(ContactQuery.SORTORDER_DESCENDING);
    service.getContactFeed(query, new ContactFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Contacts feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactFeed result) {
            ContactEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("No contacts were found that were modified today.", false);
            } else {
                showData(entries);
            }
        }
    });
}

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

License:Apache License

/**
 * Retrieves a contacts feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * On success, obtain the first contact entry with a title starting
 * with "GWT-Contacts-Client", this is the contact that will be updated.
 * If no contact is found, display a message.
 * Otherwise call updateContact to update the contact.
 * /* w w w .j  a v  a 2  s  . c  om*/
 * @param contactsFeedUri The contacts feed uri
 */
private void queryContacts(String contactsFeedUri) {
    showStatus("Querying contacts...", false);
    ContactQuery query = ContactQuery.newInstance(contactsFeedUri);
    Date today = new Date();
    DateTime updatedMin = DateTime.newInstance(today, true);
    query.setUpdatedMin(updatedMin);
    query.setSortOrder(ContactQuery.SORTORDER_DESCENDING);
    service.getContactFeed(query, new ContactFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Contacts feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactFeed result) {
            ContactEntry[] entries = result.getEntries();
            ContactEntry targetContact = null;
            for (ContactEntry contact : entries) {
                String title = contact.getTitle().getText();
                if (title.startsWith("GWT-Contacts-Client")) {
                    targetContact = contact;
                    break;
                }
            }
            if (targetContact == null) {
                showStatus("No contacts were found that were modified today and "
                        + "contained 'GWT-Contacts-Client' in the title.", false);
            } else {
                updateContact(targetContact);
            }
        }
    });
}