Package com.google.gdata.client

Examples of com.google.gdata.client.Query


  private CalendarEventEntry findEntryForProgram(GoogleService myService, URL postUrl, String title, Program program) throws IOException, ServiceException {
    Calendar c = CalendarToolbox.getStartAsCalendar(program);
    DateTime startTime = new DateTime(c.getTime(), c.getTimeZone());

    Query myQuery = new Query(postUrl);
    myQuery.setFullTextQuery(title);
    CalendarEventFeed myResultsFeed = myService.query(myQuery, CalendarEventFeed.class);

    for (CalendarEventEntry entry : myResultsFeed.getEntries()) {
      if ((entry.getTimes().size() > 0) && (entry.getTimes().get(0).getStartTime().getValue() == startTime.getValue())) {
        return entry;
View Full Code Here


  }

  @Override
  public List<PhotoEntry> findPhotos(String title, int count)
      throws MalformedURLException, IOException, ServiceException {
    Query myQuery = new Query(new URL(getPicasaURL()));
    myQuery.setStringCustomParameter("kind", "photo");
    myQuery.setMaxResults(count);
    myQuery.setFullTextQuery(title);
    AlbumFeed feed = getPicasawebService().query(myQuery, AlbumFeed.class);
    return feed.getPhotoEntries();
  }
View Full Code Here

        } catch (AuthenticationException e) {
            throw new ContactsException("login failed", e);
        }
        try {
            URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/" + email + "/full");
            Query query = new Query(feedUrl);
            query.setMaxResults(Integer.MAX_VALUE);
            ContactFeed resultFeed = service.query(query, ContactFeed.class);
            List<Contact> contacts = new ArrayList<Contact>();
            for (ContactEntry entry : resultFeed.getEntries()) {
                for (Email email : entry.getEmailAddresses()) {
                    String address = email.getAddress();
View Full Code Here

      url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + URL_CATEGORY_FOLDER);
    } else {
      throw new DocumentListException("invaild category");
    }

    Query qry = new Query(url);

    for (String key : searchParameters.keySet()) {
      qry.setStringCustomParameter(key, searchParameters.get(key));
    }

    return service.query(qry, DocumentListFeed.class);
  }
View Full Code Here

   * @throws IOException
   */
  public GsaFeed queryFeed(String feedName, Map<String, String> queries)
                           throws MalformedURLException, ServiceException, IOException {
    URL feedUrl = getFeedUrl(feedName);
    Query query = new Query(feedUrl);

    for (Entry<String, String> q : queries.entrySet()) {
      query.setStringCustomParameter(q.getKey(), q.getValue());
    }

    GsaFeed resultsFeed = service.query(query, GsaFeed.class);
    return resultsFeed;
  }
View Full Code Here

    }
    // If ifModifiedSince is null at this point service.query() will treat it
    // as if no threshold was specified (equivalent to the 2-arg form).
   
    DateTime fetchTime = DateTime.now();
    Query query = new Query(feedUrl);
    query.setMaxResults(MAX_RESULTS);
    if (ifModifiedSince != null) {
      // The use of ifModifiedSince here filters out entries that were
      // modified before the given date.  Logically, we only care about those
      // entries that were modified recently.
      query.setUpdatedMin(ifModifiedSince);
    }
   
    Feed feed = null;
    try {
      feed = (Feed) service.query(query, Feed.class, ifModifiedSince);
View Full Code Here

            // Send an HTTP GET
            GetMethod getMethod = new GetMethod(uri);
            getMethod.setRequestHeader("Authorization", authorizationHeader);

            Object[] args = (Object[])msg.getBody();
            Query myQuery = (Query)args[0];
           
            //System.out.println("[Debug Info] GdataBindingInvoker.QueryInvoker.invoke---feedURL: " + uri);

            try {
View Full Code Here

            // Send an HTTP GET
            GetMethod getMethod = new GetMethod(uri);
            getMethod.setRequestHeader("Authorization", authorizationHeader);

            Object[] args = (Object[])msg.getBody();
            Query myQuery = (Query)args[0];
           
            System.out.println("[Debug Info] GdataBindingInvoker.QueryInvoker.invoke---feedURL: " + uri);

            try {
View Full Code Here

     
      // The URL for all contacts of the specified user
      URL conUrl = new URL( CONTACTS_FEED_URL );

      // Get Number of contacts 
      Query conQuery = new Query(conUrl);
      conQuery.setMaxResults(1);    
      ContactFeed conFeed = myService.query(conQuery, ContactFeed.class);
      if (conFeed.getTotalResults() == 0) {
        System.out.println("No Contacts");
        return;
      } else {
        // Set Number of contacts for query
        conQuery.setMaxResults(conFeed.getTotalResults());
        conFeed = myService.query(conQuery, ContactFeed.class);
     
     
/* //DEBUG:   
          System.out.println("All contacts:");
      for (ContactEntry contact : conFeed.getEntries()) {
        System.out.println("\tContact: "
            + (contact.hasName() ? contact.getName().getFullName().getValue() : "null")
            + (contact.hasBirthday() ? "\t" + contact.getBirthday().getValue() : ""));
      }
*/
     
      // Create CalendarService and authenticate using ClientLogin
      CalendarService calService = new CalendarService(APP_NAME);
      calService.setProtocolVersion(CalendarService.Versions.V2_1);
      calService.setUserCredentials(userName, userPassword);

      // The URL for the own calendars feed of the specified user
      URL calUrl = new URL ( CALENDAR_FEED_URL );

      // Get Number of calendars 
      Query calQuery = new Query(calUrl);
      calQuery.setMaxResults(1);    
      CalendarFeed calFeed = calService.query(calQuery, CalendarFeed.class);
      if (calFeed.getTotalResults() == 0) {
        System.out.println("No Calendars");
      } else {
        // Set Number of calendars for query
        calQuery.setMaxResults(calFeed.getTotalResults());
        calFeed = calService.query(calQuery, CalendarFeed.class)
      }
     
      // Search calendar
      System.out.println("Calendar to use for birthdays");
      for (CalendarEntry entry : calFeed.getEntries()) {
        if ( entry.getTitle().getPlainText().equals( CALENDAR_NAME ) ) {
          calEntry = entry;
        }
      }
      if (calEntry == null) {
        // No calendar found - Add a birthday calendar
        calEntry = new CalendarEntry();
        calEntry.setTitle(new PlainTextConstruct( CALENDAR_NAME ));
        calEntry.setSummary(new PlainTextConstruct( CALENDAR_SUMMARY ));
        calEntry.setTimeZone(calFeed.getEntries().get(0).getTimeZone());
        calEntry.setHidden(HiddenProperty.FALSE);
        calEntry.setColor(new ColorProperty( CALENDAR_COLOR ));
        calEntry.setSelected(SelectedProperty.TRUE);
        //calEntry.addLocation(new Where("", "", "Oakland"));
        //calEntry.addLocation(calFeed.getEntries().get(0).getLocations().);

          // Insert the calendar
        calService.insert(calUrl, calEntry);
        System.out.println("\tCreated: " + calEntry.getTitle().getPlainText());
        //Thread.sleep(5000);
        calQuery.setMaxResults(calFeed.getTotalResults()+1);
        calFeed = calService.query(calQuery, CalendarFeed.class)
        for (CalendarEntry entry : calFeed.getEntries()) {
          if ( entry.getTitle().getPlainText().equals( CALENDAR_NAME ) ) {
            calEntry = entry;
          }
        }
      }
      else {
        System.out.println("\tFound: " + ( (calEntry != null) ? calEntry.getTitle().getPlainText() : "null") );
      }

     
      // Get all events
      URL eventUrl = new URL ( calEntry.getLink(Link.Rel.ALTERNATE, Link.Type.ATOM).getHref() );
     
      // Get Number of events 
      Query eventQuery = new Query(eventUrl);
      eventQuery.setMaxResults(1);    
      CalendarEventFeed eventFeed = calService.query(eventQuery, CalendarEventFeed.class)
      if (eventFeed.getTotalResults() == 0) {
        System.out.println("No Events");
      } else {
        // Set Number of events for query
        eventQuery.setMaxResults(eventFeed.getTotalResults());
        eventFeed = calService.query(eventQuery, CalendarEventFeed.class);       
      }

      Boolean exists = false;
      Boolean update = false;
View Full Code Here

    }
   
   
    @Test
    public void testClientQuery() throws Exception {
        Query myQuery = new Query(new URL("http://haibotuscany.blogspot.com/feeds/posts/default"));
        myQuery.setMaxResults(100);
        //myQuery.setUpdatedMin(startTime);
        myQuery.setUpdatedMax(DateTime.now());
        Feed resultFeed = testService.clientQuery(myQuery);       
        System.out.println("Query result feed title: " + resultFeed.getTitle().getPlainText());   
        System.out.println("Query result entry number: "+ resultFeed.getEntries().size());
        //assertEquals("gdata binding tuscany test", resultFeed.getTitle().getPlainText());
     }
View Full Code Here

TOP

Related Classes of com.google.gdata.client.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.